<!DOCTYPE html>
<html lang='en'>

<head>
    <meta charset='UTF-8'>
    <meta name='viewport' content='width=device-width, initial-scale=1.0'>
    <title>Document</title>
    <script type='text/javascript' src='js/vue.js'></script>
</head>

<body>
    <div id='app'>
        {{msg}}
        ======
        <hr>
        <brother>11111111</brother>
        ============
        <sister></sister>
    </div>
    <script type='text/javascript'>

        var Bus = new Vue()

        var brother = {
            data() {
                return {
                    bb2: '哥哥说：我要给你介绍一个男朋友',
                    bb:''
                }
            },
            template: `<h1 @click='b1'>我是哥哥===={{bb}}======</h1>`,
            mounted(){
                Bus.$on('func',(message)=>{
                    this.bb=message
                    console.log(message,123);
                    
                })
            },
            methods:{
                b1(){
                    Bus.$emit('func2',this.bb2)
                }
            }
        }

        var sister = {
            data() {
                return {
                    ss: '妹妹说:我想给你介绍一个女朋友',
                    ss2:''
                }
            },
            template: `<h1 @click='s1'>我是妹妹====={{ss2}}==</h1>`,
            methods: {
                s1() {
                    Bus.$emit('func',this.ss)
                }
            },
            mounted(){
                Bus.$on('func2',(message)=>{
                    this.ss2=message
                })
            }
        }

        Vue.component('brother', brother)
        Vue.component('sister', sister)


        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'Hello Vue'
            }
        });




    </script>
</body>

</html>